﻿$y="scope.ps1:y"
$func={param([string]$caller) 
	Write-Host call from $caller
	Write-Host y=$y
	Write-Host z=$z

}



function Main{
	Write-Host "+Main ENTER"
	& $func "Main"
	$z="Main:z"
	$y="Main:y"
	& $func "Main"
	
	Remove-Module "extmod" -ErrorAction SilentlyContinue
	Import-Module ".\extmod.psm1"
	
	extcaller $func
	intcaller $func
}

function intcaller{
param ([scriptblock] $f)
	Write-Host "++intcaller ENTER"
	& $f "intcaller:f"
	$z="intcaller:z"

	& $f "intcaller:f"
	
	$f2=[Scriptblock]::Create($f)
	
	Write-Host "f->f2"
	& $f2 "intcaller:f2"
}

Main